package org.fxcontainer.controller
{
	import com.developmentarc.core.actions.ActionDelegate;
	import com.developmentarc.core.actions.actions.IAction;
	
	import org.as3commons.logging.ILogger;
	import org.as3commons.logging.LoggerFactory;
	
	/**
	 * The command controller.<br/>
	 * Performs registering command with action handlers and manage them.
	 * @author Izzet_Mustafayev
	 */
	public class CommandController extends ActionDelegate
	{
		/**
		 * The comand controller singleton instance. 
		 */
		static private var _actionDelegate:CommandController;
		
		/**
		 * The logger reference. 
		 */
		static private var logger:ILogger = LoggerFactory.getClassLogger(CommandController);
		
		/**
		 * Command controller constructor.
		 */
		public function CommandController()
		{
			super();
		}
		
		static private function get instance():ActionDelegate 
		{
			if (null == _actionDelegate){
				_actionDelegate = new CommandController();
			}
			return _actionDelegate;
		}
		
		/**
		 * Registers <code>IAction</code> within command controller.
		 * @param action the action to register
		 */
		static public function registerAction(action:IAction):void 
		{
			logger.debug("Register action \"{0}\".", action);
			instance.addAction(action);
		}		
	}
}